package com.hyt.it.ogt.kq.service.gov.service.impl;

import com.hyt.core.base.BaseServiceImpl;
import com.hyt.it.ogt.kq.service.gov.mapper.GovDictMapper;
import com.hyt.it.ogt.kq.service.gov.model.entity.Dict;
import com.hyt.it.ogt.kq.service.gov.service.GovIDictService;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 数据字典信息表 服务实现类
 * </p>
 *
 * @author huangyh
 * @since 2021-03-08
 */
@Service
public class GovDictServiceImpl extends BaseServiceImpl<GovDictMapper, Dict> implements GovIDictService {

    @Override
    public List<Dict> getSexType() {

        List<Dict> dictList = this.lambdaQuery()
                .eq(Dict::getType,"sex")
                .eq(Dict::getDelFlag,false)
                .orderByAsc(Dict::getSort)
                .list();

        return dictList;
    }

    @Override
    public List<Dict> getCardType() {
        List<Dict> dictList = this.lambdaQuery()
                .eq(Dict::getType,"card_type")
                .eq(Dict::getDelFlag,false)
                .orderByAsc(Dict::getSort)
                .list();
        return dictList;
    }

    @Override
    public Map<String,Dict> getCardTypeDict() {
        List<Dict> dictList = getCardType();
        Map<String,Dict> dictMap = new HashMap<>(dictList.size());
        dictList.stream().forEach(dict -> {
            dictMap.put(dict.getValue(),dict);
        });
        return dictMap;
    }
}
